package org.bulldog.playlist.notice;

import org.bulldog.playlist.util.DateUtil;

/**
 * Created by zhanghongbin on 2017/9/6.
 *
 * @author zhanghongbin
 * @version 1.0
 */
public final class Notice {

    private String id = "";
    private String content = "";
    private String startTime = "";
    private String endTime = "";
    private int playDuration = 0;
    private int duration = 0;
    //通知状态 0 结束 1 开始
    private int status = -1;
    //点播结束时间
    private String demandEndTime = "";

    public Notice() {

    }

    /**
     * @param id  为f_server_id
     * @param content
     * @param startTime
     * @param endTime
     */
    public Notice(String id, String content, String startTime, String endTime) {
        this.id = id;
        this.content = content;
        this.startTime = startTime;
        this.endTime = endTime;
    }

    void setDuration(int duration) {
        this.duration = duration;
        this.playDuration = duration;
    }

    void setEndTime(String endTime) {
        this.endTime = endTime;
    }

    void setStatus(int status) {
        this.status = status;
    }

    public int getStatus() {
        return status;
    }

    void setStartTime(String startTime) {
        this.startTime = startTime;
    }

    public int getDuration() {
        return duration;
    }

    void setPlayDuration(int playDuration) {
        this.playDuration = playDuration;
    }

    public String getId() {
        return id;
    }

    public String getContent() {
        return content;
    }

    public String getStartTime() {
        return startTime;
    }

    public String getEndTime() {
        return endTime;
    }

    public int getPlayDuration() {
        return playDuration;
    }

    void setDemandEndTime(String demandEndTime) {
        this.demandEndTime = demandEndTime;
    }

    public String getDemandEndTime() {
        return this.demandEndTime;
    }

    @Override
    public int hashCode() {
        //不能放到hash集合里边hashCode没有重写
        return super.hashCode();
    }

    @Override
    public boolean equals(Object obj) {
        if (obj != null && obj instanceof Notice) {
            Notice tmp = (Notice) obj;
            return DateUtil.isBetween(this.getStartTime(), tmp.startTime, tmp.endTime);
        }
        return false;
    }

    @Override
    public String toString() {
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append("{\"id\":" + "\"" + this.id + "\",").
                append("\"content\":" + "\"" + this.content + "\",").append("\"startTime\":\"" + this.startTime + "\",")
                .append("\"endTime\":\"" + this.endTime + "\",").append("\"demandEndTime\":\"" + this.demandEndTime + "\",").append("\"duration\":" + this.duration + ",")
                .append("\"playDuration\":" + this.playDuration + ",\"status\":" + this.status + "}");
        return stringBuilder.toString();
    }
}
